package com.bountytask.config;

import com.alibaba.fastjson.JSONObject;
import com.bountytask.entity.Information;
import lombok.extern.slf4j.Slf4j;

import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;
import java.util.List;

@Slf4j
public class ServerEncoder implements Encoder.Text<List<Information>> {
    @Override
    public String encode(List list)throws EncodeException{
        try {
            return JSONObject.toJSONString(list);
        }catch (Exception e){
            log.error("",e);
        }
        return null;
    }

    @Override
    public void init(EndpointConfig endpointConfig){

    }

    @Override
    public void destroy(){

    }
}
